// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: declaration of CImplActionDestroy.
//   $Id$

//<summary>
//	Implementation of the destroy element specified in 
//	XForms 1.1 (no URL available yet)
//</summary>
//<remarks>
//	Keen-eyed observers will note that this class has properties corresponding to
//	Single Node Binding Attributes.  You may think this queer, and that it should
//	inherit from CImplSingleNodeBinding, however, having seen the horrific diamond 
//	inheritance problem in setvalue and message, I think it better to avoid that.
//</remarks>

#pragma once
#include "ImplActionWithOnDemandBindings.h"
class CImplBind;
class CImplModel;
class CXFormsElementDestroy;
class CSingleNodeBindingOnDemand;

class CImplActionDestroy
	:public CImplActionWithOnDemandBindings
{
public:
	CImplActionDestroy(CXFormsElementDestroy * pXFormsElement);
	virtual ~CImplActionDestroy(void);
	
	CComBSTR m_sRef;
	CComBSTR m_sBind;
private:
	CImplBind * m_pBind;
	CSingleNodeBindingOnDemand * m_pRefEvaluator;
	//<summary>
	//  Resolve all binding for the xf:destory. This includes the m_pContextParent and m_pModel.
	//</summary>
	virtual void ResolveBindings();

	//<summary>
	//	Retrieves the node tagged for destruction.
	//</summary>	
	HRESULT GetNodeToDestroy(IXMLDOMNode ** ppNodeToDestroy);
	//<summary>
	//	Checks to see if pNodeToDestroy is eligible for destruction,
	//	then removes it from the document.
	//</summary>
	//<returns>
	//	E_INVALIDARG if pNodeToDestroy is NULL;<br />
	//	S_OK if the node was successfully removed from the document;<br />
	//	S_FALSE if the node was not eligible for destruction; <br />
	//	otherwise, an error value from IXMLDOMNode::removeChild.
	//</returns>
	HRESULT DestroyNodeIfAppropriate(IXMLDOMNode * pNodeToDestroy) const;
	virtual HRESULT PerformAction();

};
